<template>
	<page-body>
		<view class="page">
			<!-- <view class="custom-nav">
			  <view class="back-btn" @click="handleBack">{{canGoBack ? '返回' : '关闭'}}</view>
			  <view class="title">{{title}}</view>
			</view> -->
			<web-view class="szr" :src="src"  @message="handleMessage"
						@onPostMessage="handlePostMessage"
				:style="{ position: 'absolute', top: (0 + StatusBarRpx) + 'rpx', bottom: '0', width: '100%' }" />
		
		</view>
	</page-body>
</template>

<script>
	export default {
		data() {
			return {
				src:'',
				uniPlatform:''
			}; 
		},
		onLoad() {
			// uni.setNavigationBarTitle({
			// 	title:'AI数字人'
			// })
		},
		onShow() {
			this.uniPlatform = uni.getSystemInfoSync().uniPlatform;
			this.src=this.uniPlatform=='web'?'https://qgzy.zhongbenjiaoyu.cn/szr/h5szr/index.html':'https://qgzy.zhongbenjiaoyu.cn/shuziren724/index.html'
			// #ifdef H5
			
			 // #endif
			// #ifdef MP-WEIXIN
			this.src='https://qgzy.zhongbenjiaoyu.cn/szr/xcxszr/index.html'
			// #endif
			// #ifdef APP-PLUS
			this.src='https://qgzy.zhongbenjiaoyu.cn/szr/appszr/index.html' 
			// #endif
			console.log(this.src)
		},
		methods:{
			handleBack() {
			  if (this.canGoBack) {
			    this.$refs.webview.evalJs('history.back()');
			  } else {
			    uni.navigateBack();
			  }
			},
			handleMessage(e) {
			  console.log('收到消息:', e.detail);
			},
			handlePostMessage(e) {
			  const data = e.detail.data[0];
			  if (data.type === 'canGoBack') {
			    this.canGoBack = data.value;
			  } else if (data.type === 'title') {
			    this.title = data.value;
			  }
			}
		}
	}
</script>

<style lang="scss">
	.custom-nav {
	  display: flex;
	  height: 44px;
	  line-height: 44px;
	  background-color: #f8f8f8;
	  padding: 0 15px;
	}
	.back-btn {
	  width: 60px;
	}
	.title {
	  flex: 1;
	  text-align: center;
	}
	page{
		background-color: #ffffff;
	}
	.szr{
		margin-top: auto;
		height: 99%;
		// background-color: red;
		// height: calc();
	}
</style>